﻿package tests;
import flash.Lib;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;

class ListTest extends GenericTest
{	
	public function new() 
	{
		super();
		
		_tf = new TextField();
		_tf.autoSize = TextFieldAutoSize.LEFT;
		addChild(_tf);
	}
	
	override function init()
	{
		var numIterations = 100000;
		test01(numIterations);
		test01(numIterations);
		test01(numIterations);
		test01(numIterations);
		test01(numIterations);
		test01(numIterations);
	}
	
	function test01(numIterations:Int)
	{
		var random = Math.random;
		var time = Lib.getTimer();
		var array = new Array<Float>();
		var i = numIterations;
		while (i-- > 0)
		{
			array.push(Math.random());
		}
		for (element in array)
		{
			var x = element;
		}
		customTrace('array time: ' + (Lib.getTimer() - time));
	}
	
	function customTrace(value:String)
	{
		_tf.text += value + '\n';
	}
}